package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsAccountTrace;
import com.qf.service.AccoutService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/25 17:33
 */
@RequestMapping("/brokerage")
@RestController
@CrossOrigin("*")
public class BrokerageController {


    @Autowired
    private AccoutService service;

    @RequestMapping("/list")
    public  Object list(String username, String mobile,
                        @RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10") Integer limit,
                        @RequestParam(defaultValue = "add_time") String sort,
                        @RequestParam(defaultValue = "desc") String desc){
        IPage<DtsAccountTrace> list = service.list(username, mobile, page, limit, sort, desc);

        List<DtsAccountTrace> records = list.getRecords();

        long total = list.getTotal();

        HashMap<String, Object> data = new HashMap<>();
        data.put("total", total);
        data.put("traceList", records);

        return ResponseUtil.ok(data);
    }
   @PostMapping("/approve")
    public  Object approve(@RequestBody DtsAccountTrace trace){
       int update = service.update(trace);

       return  ResponseUtil.ok();
    }
}
